package com.example.javatwo.controller.cg.lch;

import java.util.List;

import org.apache.coyote.http11.filters.VoidInputFilter;
import org.apache.ibatis.annotations.Param;
import org.junit.validator.PublicClassValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.javatwo.pojo.cg.lch.Inquiryzb;
import com.example.javatwo.pojo.cg.lch.history;
import com.example.javatwo.pojo.cg.lch.pageBean;
import com.example.javatwo.service.cg.lch.xjdService;
import com.jayway.jsonpath.Predicate;

import ch.qos.logback.core.status.Status;

@Controller
public class xjdController {
	@Autowired
	private xjdService xjdservice;
	
	@RequestMapping("/cgxjch")
	public String cgxj()throws Exception{
		return "cg/lch/cgxj";
		
	}
	//查询主详
	@RequestMapping(value="/findAllz",method=RequestMethod.POST)
	@ResponseBody
	public pageBean findAllz(Integer currentpage){
		System.out.println("123.....");
		System.out.println(currentpage);
		Integer count=this.xjdservice.findCount();
		List<Inquiryzb> pageobj=this.xjdservice.findAll(currentpage);
		pageBean bean=new pageBean(count,currentpage,pageobj);
		return bean;
	}
	//主详新增
	@RequestMapping("/add")
	@ResponseBody
	public void add(@RequestBody Inquiryzb inquiryzb)throws Exception{
		System.out.println(inquiryzb);
		this.xjdservice.insertinquizb(inquiryzb);
	}
	//单号
	@RequestMapping("/querybillno")
	@ResponseBody
	public String querybillno(@Param("billDate") String billDate)throws Exception{
		String billno=xjdservice.querybillno(billDate);
		return billno;
	}
	//查询总数
	@RequestMapping("/findcount")
	@ResponseBody
	public int findcount(){
		return xjdservice.findCount();
		
	}
	//逻辑删除
	@RequestMapping("/ljsc")
	@ResponseBody
	public void ljsc(String billNo){
		System.out.println("***********************************");
		this.xjdservice.detesta(billNo);
		System.out.println("-------"+billNo);
	}
	//删除
	@RequestMapping("/delzx")
	@ResponseBody
	public String delzx(String billNo){
		System.out.println("99999.............");
		this.xjdservice.deleteszx(billNo);
		return "删除成功。。。";
	}
	//修改
	@RequestMapping("/updatequi")
	@ResponseBody
	public String updatequi(@RequestBody Inquiryzb inquiryzb){
		this.xjdservice.updates(inquiryzb);
		return "修改成功。。。";
	}
	//审核
	@RequestMapping("/status")
	@ResponseBody
	public void status(String billNo){
		System.out.println("-------"+billNo);
		this.xjdservice.shstatus(billNo);
		
	}
	//反审核
	@RequestMapping("/fanstatus")
	@ResponseBody
	public void fanstatus(String billNo){
		System.out.println("-------"+billNo);
		this.xjdservice.fanshenhe(billNo);
	}
	
	//历史交易查询
	@RequestMapping("/lsjycs")
	@ResponseBody
	public List<history> queryhistory(String customerName){
		return this.xjdservice.queryhistory(customerName);
		
	}
}
